package com.atguigu.oss.utils;

import lombok.Data;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Data
@Component
@ConfigurationProperties(prefix = "aliyun.oss.file")
//项目启动时 spring加载
//能读取值，但是加载时间不同，static先加载
public class ConstantPropertiesUtils implements InitializingBean {
    //读取配置文件内容 @value("${}")或者类上@ConfigurationProperties(prefix = "aliyun.oss.file")
    private String endPoint;
    private String keyId;
    private String keySecret;
    private String bucketName;

    //定义公开常量
    public static String END_POINT;
    public static String KEY_ID;
    public static String KEY_SECRET;
    public static String BUCKET_NAME;


    @Override
    public void afterPropertiesSet() throws Exception {
        END_POINT=endPoint;
        KEY_ID=keyId;
        KEY_SECRET=keySecret;
        BUCKET_NAME=bucketName;

    }
}
